package com.happy.study.servier.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.happy.study.dao.StuNoteMapper;
import com.happy.study.entity.StuNoteEntity;
import com.happy.study.servier.IStuNoteService;
import com.happy.study.util.StateEnum;
import com.happy.study.util.StateException;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: Wuzh
 * @Description:
 * @Date Created in 13:35 2022-08-14
 * @return
 */
@Service
public class StuNoteServiceImpl extends ServiceImpl<StuNoteMapper, StuNoteEntity> implements IStuNoteService {

    @Override
    public List<StuNoteEntity> queryList (StuNoteEntity stuNoteEntity) {
        if ( stuNoteEntity == null ) {
            throw new StateException ( StateEnum.REQUEST_PARAM_EXCE );
        }
        QueryWrapper<StuNoteEntity> queryWrapper = new QueryWrapper<> ();
        if ( stuNoteEntity.getUserId () != null ) {
            queryWrapper.eq ( "userId", stuNoteEntity.getUserId () );
        }
        if ( stuNoteEntity.getNoteId () != null ) {
            queryWrapper.eq ( "noteId", stuNoteEntity.getNoteId () );
        }
        List<StuNoteEntity> stuNoteEntities = baseMapper.selectList ( queryWrapper );
        return stuNoteEntities;
    }
}
